﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using HelloMinasan.Business;
using HelloMinasan.Business.Extend;
using HelloMinasan.Domain;

namespace HelloMinasan.Web.Song.ViewModels
{
    public class NotesModel
    {
        public IEnumerable<UserNote> UserNotes
        {
            get
            {
                int totalPageCount = 0;
                //var list = new UserIRepository().GetNotes(UserAccount, out totalPageCount, PagingControl.CurrentPageNumber);
                ISongService songService = DependencyResolver.Current.GetService<ISongService>();
                var list = songService.GetNotes(UserAccount, out totalPageCount, PagingControl.CurrentPageNumber);
                var badWords = songService.GetBadWord();

                foreach (var item in list)
                {
                    //foreach (var itemBadWords in MvcApplication.FilterWords)
                    foreach (var itemBadWords in badWords)
                    {
                        item.Comments = item.Comments.Replace(itemBadWords.Words, "BadWords");
                    }
                }
                TotalPageCount = totalPageCount;
                return list;
            }
        }
        public bool isOwner { get; set; }
        public int UserAccount { get; set; }
        public PagingHelper PagingControl { get; set; }
        public int TotalPageCount { get; set; }
    }
}